//
//  YeeShopHeaderView.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/3.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeShopHeaderView.h"
@interface YeeShopHeaderView ()<SDCycleScrollViewDelegate>
{
    SDCycleScrollView *_bannerHeaderView;

}
@end
@implementation YeeShopHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    
    if (self=[super initWithFrame:frame])
    {
        [self addOwnViews];
    }
    return self;
}
-(void)addOwnViews
{
    [self addBannerView];
    [self addContentView];
    
}
-(void)addBannerView
{
    SDCycleScrollView  *bannerHeaderView=[SDCycleScrollView  cycleScrollViewWithFrame:CGRectMake(0, 0, kMainScreenWidth,kMainBannerHight) delegate:self placeholderImage:[UIImage imageNamed:@"activity_default"]];
    bannerHeaderView.pageControlStyle=SDCycleScrollViewPageContolStyleClassic;
    bannerHeaderView.bannerImageViewContentMode=UIViewContentModeScaleAspectFill;
    bannerHeaderView.pageDotColor=kWhiteColor;
    [bannerHeaderView setBackgroundColor:kWhiteColor];
    bannerHeaderView.pageDotImage=[UIImage imageNamed:@"HX_Banner_dot_nor"];
    bannerHeaderView.currentPageDotImage=[UIImage imageNamed:@"HX_Banner_dot_current"];
    bannerHeaderView.currentPageDotColor=kNavBarThemeColor;
    bannerHeaderView.imageURLStringsGroup=@[@"http://upload-images.jianshu.io/upload_images/3356997-1f957c03fd1d4614.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",@"http://upload-images.jianshu.io/upload_images/3534836-ceb716b394ae8a63.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240",@"http://upload-images.jianshu.io/upload_images/3408986-6b247074e37310a5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"];
    _bannerHeaderView=bannerHeaderView;
    [self addSubview:bannerHeaderView];
}
-(void)addContentView
{
    //分享
    _shareButton=[UIButton buttonWithType:UIButtonTypeCustom];
   [_shareButton setImage:[UIImage imageNamed:@"icon_shezhi_weidianji"] forState:UIControlStateNormal];
    [self addSubview:_shareButton];
    [_shareButton mas_makeConstraints:^(MASConstraintMaker *make)
    {   make.right.equalTo(self).with.offset(-10);
        make.height.width.mas_equalTo(35);
        make.top.equalTo(_bannerHeaderView.mas_bottom).offset(5);
    }];
    
    _titleLable=[[UILabel alloc] init];
    _titleLable.font=[UIFont systemFontOfSize:14];
    _titleLable.textColor=kBlackColor;
    _titleLable.numberOfLines=0;
    _titleLable.text=@"袜子袜子袜子袜子袜子袜袜子袜子袜袜子袜子袜袜子袜子袜袜子袜子袜袜子袜子袜袜子袜子袜";
    [self addSubview:_titleLable];
    [_titleLable mas_makeConstraints:^(MASConstraintMaker *make)
    {   make.left.equalTo(self).with.offset(5);
        make.top.equalTo(_bannerHeaderView.mas_bottom).offset(5);
        make.right.equalTo(_shareButton.mas_left);
    }];
    
    _priceLable=[[UILabel alloc] init];
    _priceLable.font=[UIFont systemFontOfSize:14];
    _priceLable.textColor=kNavBarThemeColor;
    _priceLable.text=@"￥5000";
    [self addSubview:_priceLable];
    [_priceLable mas_makeConstraints:^(MASConstraintMaker *make)
    {   make.left.equalTo(self).with.offset(10);
        make.top.equalTo(_titleLable.mas_bottom);
        make.height.mas_equalTo(21.0f);
    }];
    
    _oldLable=[[UILabel alloc] init];
    _oldLable.font=[UIFont systemFontOfSize:14];
    _oldLable.textColor=kGrayColor;
    NSString *textStr = [NSString stringWithFormat:@"￥%@", @"23233"];
    //中划线
    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
    // 赋值
    _oldLable.attributedText = attribtStr;
    [self addSubview:_oldLable];
    [_oldLable mas_makeConstraints:^(MASConstraintMaker *make)
     {   make.left.equalTo(_priceLable.mas_right).offset(10);
         make.top.equalTo(_titleLable.mas_bottom);
         make.height.mas_equalTo(21.0f);
     }];
    _deliveryLable=[[UILabel alloc] init];
    _deliveryLable.font=[UIFont systemFontOfSize:12];
    _deliveryLable.textColor=kGrayColor;
    _deliveryLable.text=@"快递费:免费(由商家支付)";
    [self addSubview:_deliveryLable];
    [_deliveryLable mas_makeConstraints:^(MASConstraintMaker *make)
     {   make.left.equalTo(self).with.offset(10);
         make.top.equalTo(_priceLable.mas_bottom);
         make.height.mas_equalTo(21.0f);
     }];
    
    _countLable=[[UILabel alloc] init];
    _countLable.font=[UIFont systemFontOfSize:12];
    _countLable.textColor=kGrayColor;
    _countLable.text=@"20人已购买";
    [self addSubview:_countLable];
    [_countLable mas_makeConstraints:^(MASConstraintMaker *make)
     {   make.left.equalTo(_deliveryLable.mas_right).offset(5);
         make.top.equalTo(_priceLable.mas_bottom);
         make.height.mas_equalTo(21.0f);
     }];
}
@end
